<?php

namespace app\controller;

use app\BaseController;
use app\service\GoodsService;
use app\service\PageService;
use think\App;
use think\facade\View;

class Page extends BaseController
{
    private $pageService;
    private $goodsService;

    /**
     * Category constructor.
     * @param App $app
     */
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->pageService = app()->make(PageService::class);
        $this->goodsService = app()->make(GoodsService::class);
    }

    /**
     * @param $route
     * @return string
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index($route): string
    {
        $data['detail'] = $this->pageService->queryDetail($route);
        $data['brandList'] = $this->goodsService->queryListByNum('brand_id > 0', 'commission_rate desc',5);
        return View::fetch('index', $data);
    }
}
